home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / utils / copyobj / objtotext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  1.5 KB  |  81 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <libraries/dos.h>
  4. #include <workbench/workbench.h>
  5. #include <workbench/startup.h>
  6.  
  7. #include <clib/alib_protos.h>
  8. #include <clib/exec_protos.h>
  9. #include <clib/dos_protos.h>
  10. #include <clib/icon_protos.h>
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. struct Library *IconBase=NULL;
  15. void sr(char *s);
  16.  
  17. char source[200];
  18. char destination[200];
  19. main(int argc,char *argv[])
  20. {
  21.   char *s;
  22.   int i;
  23.   FILE *fo;
  24.   char **tooltype;
  25.   struct DiskObject *src;
  26.   if(argc!=2)
  27.   {
  28.      printf("ObjText version 1.0, written by Joseph Hodge\n");
  29.      printf("usage: ObjText <source.info>\n");
  30.      printf("   ie: ObjText Serial.info\n");
  31.      printf("\n");
  32.      exit(0);
  33.   }
  34.   strcpy(source,argv[1]);
  35.   strcpy(destination,source);
  36.   sr(source);
  37.   sr(destination);
  38.   i=strlen(source)-1;
  39.   while(i>=0)
  40.   {
  41.      if(source[i]=='.') break;
  42.      i--;
  43.   }
  44.   if(i) source[i]='\0';
  45. i=strlen(destination)-1;
  46.   while(i>=0)
  47.   {
  48.      if(destination[i]=='.') break;
  49.      i--;
  50.   }
  51.   if(i) destination[i]='\0';
  52.   strcat(destination,".txt");
  53.   IconBase=OpenLibrary("icon.library",0L);
  54.   if(src=GetDiskObject(source))
  55.   {
  56.        i=0;
  57.        tooltype=src->do_ToolTypes;
  58.        fo=fopen(destination,"w");
  59.        while(tooltype[i]!=NULL)
  60.        {
  61.          fprintf(fo,"%s\n",tooltype[i]);
  62.          i++;
  63.        }
  64.        fclose(fo);
  65.     FreeDiskObject(src);
  66.   }
  67.   CloseLibrary(IconBase);
  68.   exit(0);
  69. }
  70.  
  71. void sr(char *s)
  72. {
  73.    register int i;
  74.    i=strlen(s)-1;
  75.    while(i>-1)
  76.    {
  77.      if(*(s+i)<=32) *(s+i)='\0'; else break;
  78.      i--;
  79.    }
  80. }
  81.